
clear

cd "C:\code"

import delimited dataset_bordersDIFF100nb.txt, delimiters(tab) clear

*label variables
label variable deaths_per_capita "Deaths Per Capita"
*label variable weekly_incr_deaths_per_capita "Weekly Change in Deaths Per Capita"
label variable stayhome "Stay at Home"
label variable emergency "State of Emergency"
label variable nursingmustaccept "Nursing Accept Pos."
label variable novisit "No Nursing Visits"
*label variable schoolshut "Schools Closed"
label variable employeemask "Employees Masks"
label variable maskrec "Masks Recommended"
label variable maskmandatory "Mandatory Masks"
label variable parksclosed "Beaches or Parks Closed"
label variable openreverse "Re-openings Reversed"
label variable noelective "No Elective Procedures"
label variable restclosed "Restaurants Closed"
label variable barsclosed "Bars Closed"
label variable gymsclosed "Gyms Closed"
label variable spasclosed "Spas Closed"
label variable gathermax10 "Gatherings Limited to 10"
label variable gathermax100 "No Gatherings Over 100"
label variable gathermax100plus "No Gatherings Limit>100"
label variable medriskclose "Med. Risk Bus. Closed"
label variable highriskclose "High Risk Bus. Closed"
label variable higherriskclose "Higher Risk Bus. Closed"
label variable highestriskclose "Highest Risk Bus. Closed"
label variable percapincome "Per Capita Income"
label variable popdensity "Population Density"
label variable obese "Obesity"
label variable smoke "Smokers"
label variable housingdensity "Housing Density"
label variable t_first "Days Since First Case"
label variable deaths7_growth "Growth{\sub t+1}"
label variable deaths14_growth "Growth{\sub t+2}"
label variable deaths21_growth "Growth{\sub t+3}"
label variable deaths28_growth "Growth{\sub t+4}"
label variable deaths35_growth "Growth{\sub t+5}"
label variable deaths42_growth "Growth{\sub t+6}"
label variable deaths7_lgrowth "Growth{\sub t-1}"
label variable deaths14_lgrowth "Growth{\sub t-2}"
label variable deaths21_lgrowth "Growth{\sub t-3}"
label variable deaths28_lgrowth "Growth{\sub t-4}"
label variable deaths35_lgrowth "Growth{\sub t-5}"
label variable deaths42_lgrowth "Growth{\sub t-6}"
label variable deaths7_per_cap_lag "Deaths Per Cap{\sub t-1}"
label variable deaths14_per_cap_lag "Deaths Per Cap{\sub t-2}"
label variable deaths21_per_cap_lag "Deaths Per Cap{\sub t-3}"
label variable deaths28_per_cap_lag "Deaths Per Cap{\sub t-4}"
label variable deaths35_per_cap_lag "Deaths Per Cap{\sub t-5}"
label variable deaths42_per_cap_lag "Deaths Per Cap{\sub t-6}"
label variable t "Days Since March 1"
label variable avgtemp "Avg Temperature"
label variable hothumidweekdays "Hot Humid Weekdays"
label variable nursetotpop "Nursing Home Pop."
label variable hothumidweekend "Hot Humid Weekend"
label variable coldweekday "Cold Weekdays"
label variable coldweekend "Cold Weekend"
label variable age65plus "Age 65+"
label variable age85plus "Age 85+"
label variable asian "Asian"
label variable black "Black"
label variable hispanic "Hispanic"
label variable nativeamer "Native Americans"
label variable other "Other"

gen date1 = date(date, "DM20Y") 
format date1 %td
drop if date1 > mdy(12,31,2020)
drop if date1 < mdy(3,1,2020)

drop if missing(deaths42_lgrowth)

*table A.6
reg deaths7_growth deaths_per_capita deaths7_lgrowth deaths14_lgrowth deaths21_lgrowth deaths28_lgrowth deaths35_lgrowth deaths42_lgrowth t_first t  avgtemp hothumidweekdays hothumidweekend coldweekday coldweekend age65plus age85plus asian black hispanic nativeamer other percapincome  popdensity diabetes obese smoke housingdensity nursetotpop stayhome emergency nursingmustaccept novisit  employeemask  maskrec maskmandatory parksclosed openreverse noelective restclosed barsclosed gymsclosed spasclosed  gathermax10 gathermax100 gathermax100plus medriskclose highriskclose higherriskclose highestriskclose b_stayhome b_emergency b_nursingmustaccept b_novisit b_employeemask b_maskrec b_maskmandatory b_parksclosed b_openreverse b_noelective b_restclosed b_barsclosed b_gymsclosed b_spasclosed   b_gathermax10 b_gathermax100 b_gathermax100plus b_medriskclose b_highriskclose b_higherriskclose b_highestriskclose wks_stayhome wks_emergency wks_nursingmustaccept wks_novisit wks_employeemask wks_maskrec wks_maskmandatory wks_parksclosed wks_openreverse wks_noelective wks_restclosed wks_barsclosed wks_gymsclosed wks_spasclosed wks_gathermax10 wks_gathermax100 wks_gathermax100plus wks_medriskclose wks_highriskclose wks_higherriskclose wks_highestriskclose log_wks_stayhome log_wks_emergency log_wks_nursingmustaccept log_wks_novisit log_wks_employeemask log_wks_maskrec log_wks_maskmandatory log_wks_parksclosed log_wks_openrevers log_wks_noelective log_wks_restclosed log_wks_barsclosed log_wks_gymsclosed log_wks_spasclosed log_wks_gathermax10 log_wks_gathermax100 log_wks_gathermax100plus log_wks_medriskclose log_wks_highriskclose log_wks_higherriskclose log_wks_highestriskclose b_wks_stayhome b_wks_emergency b_wks_nursingmustaccept b_wks_novisit b_wks_employeemask b_wks_maskrec b_wks_maskmandatory b_wks_parksclosed b_wks_openreverse b_wks_noelective b_wks_restclosed b_wks_barsclosed b_wks_gymsclosed b_wks_spasclosed b_wks_gathermax10 b_wks_gathermax100 b_wks_gathermax100plus b_wks_medriskclose b_wks_highriskclose b_wks_higherriskclose b_wks_highestriskclose b_log_wks_stayhome b_log_wks_emergency b_log_wks_nursingmustaccept b_log_wks_novisit b_log_wks_employeemask b_log_wks_maskrec b_log_wks_maskmandatory b_log_wks_parksclosed b_log_wks_openreverse b_log_wks_noelective b_log_wks_restclosed b_log_wks_barsclosed b_log_wks_gymsclosed b_log_wks_spasclosed b_log_wks_gathermax10 b_log_wks_gathermax100 b_log_wks_gathermax100plus b_log_wks_medriskclose b_log_wks_highriskclose b_log_wks_higherriskclose b_log_wks_highestriskclose, vce(cluster countyfips) 


matrix mat = J(21,16,0)

*stayhome 
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_stayhome + c*log_wks_stayhome
    local coef=r(estimate)
    local se=r(se)

	matrix mat[1,`a'-1] = `coef' 
	matrix mat[1,`a'] = `se' 
	
}
  
  
*emergency 
    
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_emergency + c*log_wks_emergency
    local coef=r(estimate)
    local se=r(se)

	matrix mat[2,`a'-1] = `coef' 
	matrix mat[2,`a'] = `se' 
}
    
  
*nursingmustaccept 
    
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_nursingmustaccept + c*log_wks_nursingmustaccept
    local coef=r(estimate)
    local se=r(se)

	matrix mat[3,`a'-1] = `coef' 
	matrix mat[3,`a'] = `se' 
    
}
   

*novisit 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_novisit + c*log_wks_novisit

    local coef=r(estimate)
    local se=r(se)
    
	matrix mat[4,`a'-1] = `coef' 
	matrix mat[4,`a'] = `se'
}
   
	
*employeemask 
 
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_employeemask + c*log_wks_employeemask
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[5,`a'-1] = `coef' 
	matrix mat[5,`a'] = `se'
}
    

*maskrec 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_maskrec + c*log_wks_maskrec
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[6,`a'-1] = `coef' 
	matrix mat[6,`a'] = `se'
}
    

*maskmandatory 
  
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_maskmandatory + c*log_wks_maskmandatory
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[7,`a'-1] = `coef' 
	matrix mat[7,`a'] = `se'
}
   

*parksclosed 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_parksclosed + c*log_wks_parksclosed
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[8,`a'-1] = `coef' 
	matrix mat[8,`a'] = `se'
}
    

*noelective 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_noelective + c*log_wks_noelective
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[9,`a'-1] = `coef' 
	matrix mat[9,`a'] = `se'
}
   
*restclosed 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_restclosed + c*log_wks_restclosed
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[10,`a'-1] = `coef' 
	matrix mat[10,`a'] = `se'
}
   


*barsclosed 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_barsclosed + c*log_wks_barsclosed
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[11,`a'-1] = `coef' 
	matrix mat[11,`a'] = `se'
}
    

*gymsclosed 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_gymsclosed + c*log_wks_gymsclosed
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[12,`a'-1] = `coef' 
	matrix mat[12,`a'] = `se'
}
    


*spasclosed 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_spasclosed + c*log_wks_spasclosed
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[13,`a'-1] = `coef' 
	matrix mat[13,`a'] = `se'
}
    


*gathermax10 
  
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_gathermax10 + c*log_wks_gathermax10
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[14,`a'-1] = `coef' 
	matrix mat[14,`a'] = `se'
}
   

*gathermax100 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_gathermax100 + c*log_wks_gathermax100
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[15,`a'-1] = `coef' 
	matrix mat[15,`a'] = `se'
}


*gathermax100plus 
    
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_gathermax100plus + c*log_wks_gathermax100plus
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[16,`a'-1] = `coef' 
	matrix mat[16,`a'] = `se'
}
    

*medriskclose 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_medriskclose + c*log_wks_medriskclose
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[17,`a'-1] = `coef' 
	matrix mat[17,`a'] = `se'
}
    

*highriskclose 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_highriskclose + c*log_wks_highriskclose
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[18,`a'-1] = `coef' 
	matrix mat[18,`a'] = `se'
}
   

*higherriskclose 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_higherriskclose + c*log_wks_higherriskclose
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[19,`a'-1] = `coef' 
	matrix mat[19,`a'] = `se'
}
   

*highestriskclose 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_highestriskclose + c*log_wks_highestriskclose
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[20,`a'-1] = `coef' 
	matrix mat[20,`a'] = `se'
}
   

*openreverse 
   
forvalues a = 1/16 {
    if inlist(`a',1,2,3,5,6,7,9,10,11,13,14,15) continue
 
    scalar c = ln(`a'+1)
    lincom `a'*wks_openreverse + c*log_wks_openreverse
 local coef=r(estimate)
    local se=r(se)
    
	matrix mat[21,`a'-1] = `coef' 
	matrix mat[21,`a'] = `se'
}
    
    
  putexcel set "C:\code\output\tableA6.xlsx", modify sheet("1")
  putexcel A1 = matrix(mat)

